package com.sumainfor.common.visitor;

import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
import net.sf.jsqlparser.expression.operators.relational.ItemsListVisitor;
import net.sf.jsqlparser.expression.operators.relational.MultiExpressionList;
import net.sf.jsqlparser.statement.select.SubSelect;

import java.util.List;

/**
 * @Author Jack Chen
 * @Create 2019-01-18 18:39
 */
public class ItemsListVisitorImpl implements ItemsListVisitor {

    private CustomExpressionEntity expressionEntity;

    public ItemsListVisitorImpl(CustomExpressionEntity expressionEntity) {
        this.expressionEntity = expressionEntity;
    }

    @Override
    public void visit(SubSelect subSelect) {
        subSelect.getSelectBody().accept(new SelectVisitorImpl(expressionEntity));
    }

    @Override
    public void visit(ExpressionList expressionList) {
        List<Expression> list = expressionList.getExpressions();
        if (list != null && !list.isEmpty()) {
            for (Expression expr : list) {
                expr.accept(new ExpressionVisitorImpl(expressionEntity));
            }
        }

    }

    @Override
    public void visit(MultiExpressionList multiExprList) {

    }
}
